#include "stdafx.h"
#include "wf_blocksadd.h"

#include "pf_graphic.h"
#include "pf_dialogfactory.h"


WF_BlocksAdd::WF_BlocksAdd(PF_Container& container,
                                       PF_GraphicView& graphicView)
        :PF_ActionInterface("Add Block", container, graphicView) {}



QAction* WF_BlocksAdd::createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/) {
	// tr("Add Block")
    QAction* action = new QAction(tr("&Add Block"), NULL);	
    //action->zetStatusTip(tr("Add Block"));
	action->setIcon(QIcon(":/ui/blockadd.png"));
    return action;
}



void WF_BlocksAdd::trigger() {
    PF_DEBUG->print("adding block");
    //PF_Block* block = new PF_Block(container, "", PF_Vector(0.0,0.0));
    if (graphic!=NULL) {
		PF_BlockList* blockList = graphic->getBlockList();
		if (blockList!=NULL) {
			PF_BlockAttribute d = 
				PF_DIALOGFACTORY->requestNewBlockDialog(blockList);
			if (d.isValid()) {
        		graphic->addBlock(new PF_Block(container, d));
			}
		}
    }
    finish();
}



void WF_BlocksAdd::init(int status) {
    PF_ActionInterface::init(status);
    trigger();
}

// EOF
